@extends('layouts.admin')

@section('title', '年级-添加')

@section('style')
    <link rel="stylesheet" type="text/css" href="{{asset('lib/bootstrap/css/bootstrap.min.css')}}" />
    <link rel="stylesheet" type="text/css" href="{{asset('lib/bootstrap/css/bootstrap-combobox.css')}}" />
@endsection

@section('content')
    <article class="page-container">
        <form action="" method="post" class="form form-horizontal" id="form-techValue-add">
            <input type="hidden" name="id" value="{{$editEntity->id}}">
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>名字：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="{{$editEntity->name}}" placeholder="" id="name" name="name">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>年级组长：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <select class="combobox input-large form-control" name="leader_user_id" id="leader_user_id">
                        @foreach ($users['data'] as $user)
                            <option value="{{$user['id']}}">{{$user['name']}}</option>
                        @endforeach
                    </select>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>学习时间：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <div class="row" style="margin-top:0;">
                        <div class="col-xs-4 col-sm-4">
                            <input type="text" onfocus="WdatePicker()" value="{{$editEntity->entrance_date}}" placeholder="入学时间" id="entrance_date" name="entrance_date" class="input-text Wdate">
                        </div>
                        <div class="col-xs-1 col-sm-1">
                            至
                        </div>
                        <div class="col-xs-4 col-sm-4">
                            <input type="text" onfocus="WdatePicker()" value="{{$editEntity->graduate_date}}" placeholder="毕业时间" id="graduate_date" name="graduate_date" class="input-text Wdate">
                        </div>
                    </div>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>班级数量：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text disabled" value="{{$editEntity->clbum_cnt}}" placeholder="" id="clbum_cnt" name="clbum_cnt" readonly>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">介绍：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <textarea name="desc" id="desc" cols="" rows="" class="textarea"  placeholder="一些介绍信息">{{$editEntity->desc}}</textarea>
                </div>
            </div>
            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                </div>
            </div>
        </form>
    </article>
@endsection
@section('script')
    <script type="text/javascript" src="{{asset('lib/bootstrap/bootstrap-combobox.js')}}"></script>
    <script>
        $('#leader_user_id').val('{{$editEntity->leader_user_id}}');
        $('.combobox').combobox();
        $(".input-text,.textarea").Huifocusblur();
        $(".textarea").Huitextarealength({
            minlength:0,
            maxlength:200.
        });
        $("#form-techValue-add").validate({
            rules:{
                name:{
                    required:true
                },
                leader_user_id:{
                    required:true,
                },
                entrance_date:{
                    required:true,
                },
                graduate_date:{
                    required:true,
                },
                clbum_cnt:{
                    required:true,
                    min:1,
                    digits:true
                },
                desc:{
                    maxlength:200,
                }
            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                $(form).ajaxSubmit({
                    type: 'post',
                    url: "{{url('clbum/grade/edit')}}",
                    success: function(data){
                        if(data['successFlag']==1){
                            layer_success_message("操作成功!");
                            setTimeout(function(){
                                parent.$(".btnSearch").click();
                                layer_close();
                            },500);
                        }else{
                            layer_error_message(data['msg']);
                        }
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer_error_message('操作失败!');
                    }
                });
            }
        });
    </script>
@endsection